home *** CD-ROM | disk | FTP | other *** search
- #include <Types.h>
- #include <Memory.h>
- #include <SetUpA4.h>
- #include <QuickDraw.h>
-
- /* This WDEF is almost too simple. First, call through to the normal system WDEF
- ** for all messages. This includes the wCalcRgns message. After coming back
- ** from the system WDEF, we know that the regions aren't as we want. Inset the
- ** structure region a bit to get rid of the stupid 3-pixel white border.
- ** That's it. */
-
- typedef pascal long (*WDEFProcPtr)(short sel, WindowPeek wnd, short msg, long prm);
-
-
-
- /*****************************************************************************/
-
-
-
- pascal long main(short sel, WindowPeek wnd, short msg, long prm)
- {
- #pragma unused (sel, prm)
-
- char hstate;
- long keepA4, ll;
- RgnHandle srgn, crgn;
- short sleft, cleft;
- WDEFProcPtr proc;
- GrafPtr wm;
- RgnHandle wmVis;
- static Handle sysWDEF;
-
- RememberA0();
- SetUpA4();
-
- if (!sysWDEF) sysWDEF = GetResource('WDEF', 0);
- /* If we don't have it yet, go get a reference to the system WDEF. We are actually
- ** being extra paranoid here, as the only reason that we should keep a reference is
- ** that somebody else in our resource chain may have a 'WDEF' id #0. After the
- ** window is created (maybe it is created once, and then shown and hidden), the
- ** resource chain could be changed. Therefore we get a reference the first time
- ** we are called. The user either:
- ** 1) Doesn't care, because they don't play goofy resource games.
- ** 2) The user cares, so they should create one of these windows early on so that
- ** the reference is cached. They can then play goofy resource games.
- */
-
- if (msg == wDraw) {
- GetPort(&wm);
- CopyRgn(wm->visRgn, wmVis = NewRgn());
- DiffRgn(wm->visRgn, wnd->contRgn, wm->visRgn);
- }
-
- if (sysWDEF) { /* Check for existence, just in case. (Paranoia again.) */
- hstate = HGetState(sysWDEF);
- HLock(sysWDEF);
- proc = (WDEFProcPtr)*sysWDEF;
- ll = (*proc)(sel, wnd, msg, prm); /* Call the real WDEF for all messages. */
- HSetState(sysWDEF, hstate);
- }
-
- if (msg == wCalcRgns) { /* If the message was to calc regions, */
- srgn = wnd->strucRgn;
- crgn = wnd->contRgn;
- sleft = (*srgn)->rgnBBox.left;
- cleft = (*crgn)->rgnBBox.left;
- if (sleft + 6 < cleft) InsetRgn(srgn, 3, 3); /* adjust the structRgn inward 3 pixels. */
- }
-
- if (msg == wDraw) {
- CopyRgn(wmVis, wm->visRgn);
- DisposeRgn(wmVis);
- }
-
- RestoreA4();
- return(ll);
- }
-
-
-
-